#pragma once
#include <string>
#include <sstream>

//
//  Unsigned types

/// Unsigned 64 bit
typedef unsigned long long uint64;
/// Unsigned 32 bit 
typedef unsigned int uint32;
/// Unsigned 16 bit
typedef unsigned short int uint16;
/// Unsigned 8 bit
typedef unsigned char uint8;

//
//  Signed types

/// Signed 64 bit
typedef long long int64;
/// Signed 32 bit
typedef int int32;
/// Signed 16 bit
typedef short int int16;
/// Signed 8 bit 
typedef char int8;

//
//  Float point

#ifdef AS_FLOAT
typedef float Float;
#else
typedef double Float;
#endif

//
//  Strings

#ifdef ADVANCED_LANG 
// Advanced localization
#include <clocale>
typedef std::wstring String;
typedef std::wstringstream StringStream;
typedef uint32 Char;
#define PRINT_SARG ("%ls")
#define PRINT_CARG ("%lc")
#else
// Basic localization
typedef std::string String;
typedef std::stringstream StringStream;
typedef int16 Char;
#define PRINT_SARG ("%s")
#define PRINT_CARG ("%c")
#endif

// 
//  Policies
struct Policy {
  enum Enum {
    AllowUserManagement = 1<<0, 
    AllowMail           = 1<<1,
    AllowFileSharing    = 1<<2,
    AllowCalendar       = 1<<3,
    AllowToDo           = 1<<4,
    AllowDirectory      = 1<<5,
    AllowTime           = 1<<6,
    AllowWebServer      = 1<<7,
    AllowChat           = 1<<8
  };
  typedef int16 Type;
};

//
//  Roles
struct Role {
  enum Enum {
    User          = 0,
    Administrator = 1
  };
  typedef enum Enum Type;
};

//
//  Codes
struct Code {
  enum Enum {
    // Common
    Okay          = 0x0000,
    InternalError = 0x0001,

		// NS
		NS_DoesntRespond		= 0x0021,
		NS_ServerNotFound		= 0x0022,
		NS_CantConvert  		= 0x0023,
		
		// AN
		AN_DoesntRespond     = 0x0101,
		AN_PasswordUncorrect = 0x0102,

    // AR
    AR_DoesntRespond = 0x0201,

    // US
    US_DBDoesntRespond  = 0x0301,
    US_QueryError       = 0x0302,
    US_DataFetchError   = 0x0303,
    US_Forbidden        = 0x0304,

    // FS
    FS_FunctionCallFailure  = 0x0601,
    FS_Forbidden            = 0x0602,
    FS_SendFailure          = 0x0603,
    FS_AssemblyFailure      = 0x0604,

		// DR
		DR_FunctionCallFailure 	 = 0x0901,
		DR_Forbidden						 = 0x0902,
		DR_FieldManagementError	 = 0x0903,
		DR_RecordManagementError = 0x0904,
	
    // WS
    WS_Forbidden            = 0x0B01,
    WS_SendFailure          = 0x0B02,
    WS_AssemblyFailure      = 0x0B03,
    WS_ConnectError         = 0x0B04,
    WS_ServerNotFound       = 0x0B05,
    WS_ParseError           = 0x0B06,
    WS_UnknownScheme        = 0x0B07,
    WS_ResiveFailure        = 0x0B08,
    
    // CT
    CT_FunctionCallFailure  = 0x0C01,
    CT_DoesntRespond        = 0x0C02
  };
  typedef enum Enum Type;
};
